tree grammar TxtTreeGrammar;

options {
  ASTLabelType = CommonTree; 
  output       = template;
}

// Tokens used internally by Moca
// ID: ('a'..'z' | 'A'..'Z')+;
// STRING: ( ID | ('0'..'9') )+; 
// ATRIBUTE: Used as an imaginary token for coding attributes in XML files (ATTRIBUTE name=ID value=STRING)
tokens {
  ID;
  STRING;
  ATTRIBUTE; 
} 
  
@header {
package org.moflon.moca.txt.unparser;
}
// tree grammar rules:
main: ^('BOARD' rows+=row*)
    -> board(rows={$rows});
   
row: ^('ROW' fields+=field*)
    -> row(fields={$fields});
    
field: ^('FIELD' (figure=STRING)?)
  -> field(figure={$figure});
